< previous page page_510 next page >

Page 510
Editing Data
To edit the data on the form, the user simply needs to type in any of the text boxes, change the value in the combo box, or change a value in an option button or check box. Of course, you need to have code under each of these controls to detect when their values change. You need code in the Change() events of the text boxes and in the Click events of the combo boxes, option buttons, and check boxes. Heres the code you should place in each of these controls:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub txtLast_Change()
   Call TextChanged
End Sub
The procedure TextChanged is responsible for toggling command buttons and setting up for the editing of data. Of course, if the buttons have already been toggled, this needs to be detected also.
Detecting That Data Has Changed
The TextChanged procedure is actually very simple to code:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub TextChanged()
   If Not mboolShow Then
      If Not cmdSave.Enabled Then
         Call ToggleButtons
      End If
   End If
End Sub
In this routine, you first check the mboolShow variable to see whether its a True value. If it is a True value, you know that the values are changing because the FormShow procedure is updating the text boxes to a new employee record. In this case, you dont want to toggle any buttons. If the variable is a False value, you need to check the cmdSave command buttons Enabled property to see whether its False. If it is False, you know that you havent already toggled the buttons and that you should toggle them so that the New and Delete command buttons are disabled and the Save command button is enabled. In addition, you should toggle the Caption property of the Close command button to &Cancel so that the user has the option of canceling the changes he or she just made. Lets take a look at the ToggleButtons procedure:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub ToggleButtons()
   If cmdClose.Caption = "&Close" Then

 
< previous page page_510 next page >

If you like this book, buy it!